package j21;

import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

/**
 * @author chengshuai
 * @date 2021/4/10 10:49
 */
public class ListRemoveDemo {

    static List<String> list = new ArrayList<>();

    public static void main(String[] args) {
        list.add("1");
        list.add("2");
        list.add("5");

        ListIterator<String> iterator = list.listIterator();
        while (iterator.hasNext()) {
            String s = iterator.next();
            if (s.equals("5")) {
                iterator.remove();
//                iterator.add("6");
            }
        }

        System.out.println(list);

    }
}
